//
//  TabBarController.swift
//  TravelNotes
//
//  Created by 千锋 on 16/8/15.
//  Copyright © 2016年 胡光健. All rights reserved.
//

import UIKit

class TabBarController: UITabBarController {
    
    override func viewDidLoad() {
        super.viewDidLoad()
        
        // 攻略
        let seizeVC = SeizeViewController()
        let seizeNav = UINavigationController(rootViewController: seizeVC)
        
        // 必备
        let mustHaveVC = MustHaveViewController()
        let mustHaveNav = UINavigationController(rootViewController: mustHaveVC)
        
        // 札记
        let readingVC = ReadingViewController()
        let readingNav = UINavigationController(rootViewController: readingVC)
        
        // 我的
        let myVC = MyViewController()
        let myNav = UINavigationController(rootViewController: myVC)
        
        
        let navArray = [readingNav, seizeNav, mustHaveNav, myNav]
        self.viewControllers = navArray
        
        
        
        let titleArray = ["札记","攻略","必备","我的"]
        
        let unselectedImageArray = ["zhaji1","gonglue1","bibei1","wode1"]
        
        let selectedImageArray = ["zhaji2","gonglue2","bibei2","wode2"]
        
        for i in 0..<navArray.count {
            let nav = navArray[i]
            nav.tabBarItem.title = titleArray[i]
            
            let unselectesImage = UIImage(named: unselectedImageArray[i])
            nav.tabBarItem.image = unselectesImage?.imageWithRenderingMode(.AlwaysOriginal)
            
            let selectImage = UIImage(named: selectedImageArray[i])
            nav.tabBarItem.selectedImage = selectImage?.imageWithRenderingMode(.AlwaysOriginal)
        }
        UITabBarItem.appearance().setTitleTextAttributes([NSForegroundColorAttributeName: UIColor.RGBA(85, 164, 154)], forState: .Selected)
    }
}
